package com.tongtech.knowledge.service.impl;

import com.tongtech.knowledge.domain.Knowledge;
import com.tongtech.knowledge.mapper.KnowledgeMapper;
import com.tongtech.knowledge.service.IKnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户管理 服务实现
 *
 * @author xingyc
 */
@Service
public class KnowledgeServiceImpl implements IKnowledgeService
{
    @Autowired
    private KnowledgeMapper knowledgeMapper;


    /**
     * 查询客户管理数据
     *
     * @param knowledge 客户信息
     * @return 客户信息集合
     */
    @Override
    public List<Knowledge> selectKnowledgeList(Knowledge knowledge)
    {
        List<Knowledge> list = knowledgeMapper.selectKnowledgeList(knowledge);

        return list;
    }

    /**
     * 根据客户ID查询信息
     *
     * @param knowledgeId 客户ID
     * @return 客户信息
     */
    @Override
    public Knowledge selectKnowledgeById(Long knowledgeId)
    {
        Knowledge knowledge = knowledgeMapper.selectKnowledgeById(knowledgeId);
        updateKnowledgeViewNum(knowledgeId);
        return knowledge;
    }

    /**
     * 新增保存客户信息
     *
     * @param knowledge 客户信息
     * @return 结果
     */
    @Override
    public int insertKnowledge(Knowledge knowledge)
    {
        return knowledgeMapper.insertKnowledge(knowledge);
    }

    @Override
    public int updateKnowledgeViewNum(Long knowledgeId) {
        return knowledgeMapper.updateKnowledgeViewNum(knowledgeId);
    }

    /**
     * 修改保存客户信息
     *
     * @param knowledge 客户信息
     * @return 结果
     */
    @Override
    public int updateKnowledge(Knowledge knowledge)
    {
        int result = knowledgeMapper.updateKnowledge(knowledge);
        return result;
    }

    /**
     * 删除客户管理信息
     *
     * @param deptId 客户ID
     * @return 结果
     */
    @Override
    public int deleteKnowledgeById(Long deptId)
    {
        return knowledgeMapper.deleteKnowledgeById(deptId);
    }
}
